import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:wanchong/conf.dart';
import 'package:wanchong/widget/tag.dart';

class StoreItem extends StatelessWidget {
  //宠物店图片
  final Widget storeImg;
  //宠物店名称
  final String storeName;
  //宠物店地址
  final String addr;
  //宠物店分类
  final String catName;
  //宠物店位置
  final String addrName;
  //宠物店距离
  final double distance;

  final List<String> tags;

  final Function onPress;
  StoreItem({
    Key key,
    this.storeImg,
    this.storeName,
    this.addr,
    this.catName,
    this.addrName,
    this.distance,
    this.tags,
    this.onPress,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: () {
        onPress();
      },
      child: Container(
        padding: EdgeInsets.only(
          left: ScreenUtil().setWidth(15.0),
          right: ScreenUtil().setWidth(15.0),
        ),
        alignment: Alignment.center,
        color: Colors.white,
        child: Row(
          children: <Widget>[
            Container(
              decoration: BoxDecoration(
                border: Border.all(
                  color: Color(BorderColor),
                  width: ScreenUtil.getInstance().setWidth(1.0),
                ),
                borderRadius: BorderRadius.circular(5),
              ),
              margin: EdgeInsets.only(
                right: ScreenUtil.getInstance().setWidth(15.0),
              ),
              width: ScreenUtil().setWidth(60.0),
              height: ScreenUtil().setHeight(60.0),
              child: storeImg,
            ),
            Expanded(
              child: Column(
                children: <Widget>[
                  Container(
                    margin: EdgeInsets.only(
                        top: ScreenUtil().setHeight(10.0),
                        bottom: ScreenUtil().setHeight(8.0)),
                    child: Text(
                      storeName,
                      style: TextStyle(
                        fontSize: ScreenUtil().setSp(16.0),
                        color: Color(MainColor),
                        fontWeight: FontWeight.w700,
                      ),
                    ),
                    width: double.infinity,
                  ),
                  Container(
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: <Widget>[
                        Row(
                          children: <Widget>[
                            Text(addr),
                            SizedBox(
                              width: ScreenUtil().setWidth(10.0),
                            ),
                            Text(catName)
                          ],
                        ),
                        Row(
                          children: <Widget>[
                            Text(addrName),
                            Container(
                              margin: EdgeInsets.only(
                                  left: ScreenUtil().setWidth(10.0),
                                  right: ScreenUtil().setWidth(10.0)),
                              width: ScreenUtil().setWidth(1.0),
                              height: ScreenUtil().setHeight(12.0),
                              color: Color(CCColor),
                            ),
                            Text(distance < 100 ? "<100m" : ">100m")
                          ],
                        ),
                      ],
                    ),
                  ),
                  Container(
                    // color: Colors.red,
                    margin: EdgeInsets.only(
                        top: ScreenUtil().setHeight(8.0),
                        bottom: ScreenUtil().setHeight(10.0)),
                    width: double.infinity,
                    child: Wrap(
                        spacing: 8.0,
                        children:
                            tags.map((value) => Tag(text: value)).toList()),
                  ),
                  Divider(
                    color: Color(BColor),
                    height: ScreenUtil().setHeight(1.0),
                  ),
                ],
              ),
            )
          ],
        ),
      ),
    );
  }
}
